/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

/**
 *
 * @author Karnit Genchay
 */
public class Submarine {
    private int size;
    private String name;
    private String position; //A-J][1-9]?
    private String direction;//   HORIZONTAL,    VERTICAL
    private Square [] squares;

    public Square[] getSquares() {
        return squares;
    }
    
    public Submarine(int size,String name,String position, String direction){
    this.size = size;
    this.name = name;
    this.position = position;
    this.direction = direction;
    this.squares = new Square[size];
    
    }

    public void unSetSubmarine(){
        for (int i = 0; i < squares.length; i++) {
            squares[i].unSetSubmarine();
        }
    }
    public int getSize(){ return size;}
    public String getPosition(){return position;}    
    public String getDirection(){return direction;}
    public void  setSquare(int i,Square square)
    {
        squares[i]=square;
    }
    public void set(String position,String direction){
        this.position = position;
        this.direction = direction;
    }
    public boolean isDown() { 
        int squaresHit=0;
        
        for (int i = 0; i < size; i++) 
            if (squares[i].getVal()=='X')
                squaresHit++;

        return (squaresHit==size);
    }
     @Override
    public String toString(){
        return "name: "+ name +", size:  "+size +", position: "+position+", direction: "+direction;
    }

    public String  getName() {
        return this.name;
    }

    public void setSize(int size) {
        this.size = size;
    }
    
    public void setName(String name) {
        this.name = name;
    }
}